﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ThreadStart childthreat =
                         new ThreadStart(childthreadcall);
        Response.Write("Child Thread Started <br/>");
        Thread child = new Thread(childthreat);
        child.Start();
        Response.Write(
           "Main sleeping  for 2 seconds.......<br/>");
        Thread.Sleep(2000);
        Response.Write(
           "<br/>Main aborting child thread<br/>");
        child.Abort();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    }

    public void childthreadcall()
      {
      try{
         lblmessage.Text = "<br />Child thread started <br/>";
         lblmessage.Text += "Child Thread: Coiunting to 10";
         for( int i =0; i<10; i++)
         {
            Thread.Sleep(500);
            lblmessage.Text += "<br/> in Child thread </br>";
         }
         lblmessage.Text += "<br/> child thread finished";
      }
      catch(ThreadAbortException e)
      {
         lblmessage.Text += "<br /> child thread - exception";
      }
      finally{
         lblmessage.Text += "<br /> child thread - unable to catch the exception";
      }
}}